%% Author: zj
%% Created: 2012-3-1
%% Description: TODO: Add description to data_era
-module(data_era).

%%
%% Include files
%%

%%
%% Exported Functions
%%
-compile(export_all).

%%
%% API Functions
%%
%%等级评价对应关卡奖励
%%[经验,灵力,修为,绑定铜,物品类型,物品数量]
get_level_prize(Stage,Level) ->
	case Level of
		1 -> 
			case Stage of
				30 -> [25000,12500,1000,0,0,0];
				35 -> [50000,25000,1250,0,0,0];
				40 -> [100000,50000,1750,0,0,0];
				45 -> [150000,75000,2100,0,0,0];
				50 -> [200000,100000,2750,0,0,0];
				55 -> [250000,125000,3500,0,0,0];
				60 -> [300000,150000,4000,0,0,0];
				65 -> [350000,175000,5000,0,0,0];
				70 -> [400000,200000,6000,0,0,0];
				75 -> [450000,225000,7000,0,0,0];
				80 -> [500000,250000,8000,0,0,0];
				85 -> [550000,275000,9000,0,0,0];
				90 -> [600000,300000,10000,0,0,0];
				95 -> [650000,325000,11500,0,0,0];
				100 -> [700000,350000,13000,0,0,0];
				_ -> [0,0,0,0,0,0]
			end;
		2 -> 
			case Stage of
				30 -> [50000,25000,2000,0,0,0];
				35 -> [100000,50000,2500,0,0,0];
				40 -> [200000,100000,3500,0,0,0];
				45 -> [300000,150000,4200,0,0,0];
				50 -> [400000,200000,5500,0,0,0];
				55 -> [500000,250000,7000,0,0,0];
				60 -> [600000,300000,8000,0,0,0];
				65 -> [700000,350000,10000,0,0,0];
				70 -> [800000,400000,12000,0,0,0];
				75 -> [900000,450000,14000,0,0,0];
				80 -> [1000000,500000,16000,0,0,0];
				85 -> [1100000,550000,18000,0,0,0];
				90 -> [1200000,600000,20000,0,0,0];
				95 -> [1300000,650000,23000,0,0,0];
				100 -> [1400000,700000,26000,0,0,0];
				_ -> [0,0,0,0]
			end;
		3 -> 
			case Stage of
				30 -> [75000,37500,3000,50000,0,0];
				35 -> [150000,75000,3750,55000,0,0];
				40 -> [300000,150000,5250,60000,0,0];
				45 -> [450000,225000,6300,65000,0,0];
				50 -> [600000,300000,8250,70000,0,0];
				55 -> [750000,375000,10500,75000,0,0];
				60 -> [900000,450000,12000,80000,0,0];
				65 -> [1050000,525000,15000,85000,0,0];
				70 -> [1200000,600000,18000,90000,0,0];
				75 -> [1350000,675000,21000,95000,0,0];
				80 -> [1500000,750000,24000,100000,0,0];
				85 -> [1650000,825000,27000,105000,0,0];
				90 -> [1800000,900000,30000,110000,0,0];
				95 -> [1950000,975000,34500,115000,0,0];
				100 -> [2100000,1050000,39000,120000,0,0];
				_ -> [0,0,0,0,0,0]
			end;
		4 -> 
			case Stage of
				30 -> [100000,50000,4000,100000,0,0];
				35 -> [200000,100000,5000,110000,0,0];
				40 -> [400000,200000,7000,120000,0,0];
				45 -> [600000,300000,8400,130000,0,0];
				50 -> [800000,400000,11000,140000,0,0];
				55 -> [1000000,500000,14000,150000,0,0];
				60 -> [1200000,600000,16000,160000,0,0];
				65 -> [1400000,700000,20000,170000,0,0];
				70 -> [1600000,800000,24000,180000,0,0];
				75 -> [1800000,900000,28000,190000,0,0];
				80 -> [2000000,1000000,32000,200000,0,0];
				85 -> [2200000,1100000,36000,210000,0,0];
				90 -> [2400000,1200000,40000,220000,0,0];
				95 -> [2600000,1300000,46000,230000,0,0];
				100 -> [2800000,1400000,52000,240000,0,0];
				_ -> [0,0,0,0,0,0]
			end;
		5 -> 
			case Stage of
				30 -> [125000,62500,5000,0,22000,5];
				35 -> [250000,125000,6250,0,24400,5];
				40 -> [500000,250000,8750,0,24104,5];
				45 -> [750000,375000,10500,0,32027,10];
				50 -> [1000000,500000,13750,0,32016,10];
				55 -> [1250000,625000,17500,0,24822,10];
				60 -> [1500000,750000,20000,0,24820,5];
				65 -> [1750000,875000,25000,0,24800,5];
				70 -> [2000000,1000000,30000,0,21022,10];
				75 -> [2250000,1125000,35000,0,21201,10];
				80 -> [2500000,1250000,40000,0,21362,1];
				85 -> [2750000,1375000,45000,0,21302,1];
				90 -> [3000000,1500000,50000,0,21302,1];
				95 -> [3250000,1625000,57500,0,21302,1];
				100 -> [3500000,1750000,65000,0,21302,1];
				_ -> [0,0,0,0,0,0]
			end;
		6 -> 
			case Stage of
				30 -> [150000,75000,6000,0,22007,2];
				35 -> [300000,150000,7500,0,24401,2];
				40 -> [600000,300000,10500,0,24105,2];
				45 -> [900000,450000,12600,0,32028,15];
				50 -> [1200000,600000,16500,0,32022,15];
				55 -> [1500000,750000,21000,0,24823,15];
				60 -> [1800000,900000,24000,0,24821,5];
				65 -> [2100000,1050000,30000,0,24800,10];
				70 -> [2400000,1200000,36000,0,21023,5];
				75 -> [2700000,1350000,42000,0,21101,10];
				80 -> [3000000,1500000,48000,0,21352,1];
				85 -> [3300000,1650000,54000,0,21322,1];
				90 -> [3600000,1800000,60000,0,21322,1];
				95 -> [3900000,1950000,69000,0,21322,1];
				100 -> [4200000,2100000,78000,0,21322,1];
				_ -> [0,0,0,0,0,0]
			end;
		_ -> 
			case Stage of
				_ -> [0,0,0,0,0,0]
			end
	end.

%%推荐战斗力[角色，宠物，坐骑]
recommend_battle_val(Stage) ->
	case Stage of
		30 -> [850,20,135];
		35 -> [2200,80,200];
		40 -> [5500,240,500];
		45 -> [9000,560,700];
		50 -> [12600,960,1000];
		55 -> [17000,1400,1400];
		60 -> [21000,2000,1900];
		65 -> [26000,2600,2400];
		70 -> [30000,3000,2800];
		75 -> [34000,3400,3200];
		80 -> [38000,3800,3600];
		85 -> [42000,4200,4000];
		90 -> [46000,4600,4400];
		95 -> [50000,5000,4800];
		100 ->[54000,5400,5200];
		_ -> [0,0,0,0]
	end.

%%关卡对应增加属性值[攻击，气血，法力，防御，全抗]
stage_add_attribute(Stage) ->
	case Stage of
		30 -> [100,500,50,300,100];
		35 -> [125,625,100,380,130];
		40 -> [150,750,150,460,160];
		45 -> [175,875,200,540,190];
		50 -> [200,1000,250,620,220];
		55 -> [225,1125,300,700,250];
		60 -> [250,1250,350,780,280];
		65 -> [275,1375,400,860,310];
		70 -> [300,1500,450,940,340];
		75 -> [325,1625,500,1020,370];
		80 -> [350,1750,550,1100,400];
		85 -> [375,1875,600,1180,430];
		90 -> [400,2000,650,1260,460];
		95 -> [425,2125,700,1340,490];
		100 -> [450,2250,750,1420,520];
		_ -> [0,0,0,0,0]
	end.

%%加分计算[时间加分，损耗加分]
add_score(Stage,PassTime,HpHurt) ->
	case Stage of
		30 -> 
			add_score_calc(PassTime,HpHurt,480,27,10000,3000);
		35 ->
			add_score_calc(PassTime,HpHurt,900,22,20000,5000);
		40 ->
			add_score_calc(PassTime,HpHurt,1200,22,45000,6000);
		45 ->
			add_score_calc(PassTime,HpHurt,1200,27,78000,8000);
		50 ->
			add_score_calc(PassTime,HpHurt,1200,33,100000,10000);
		55 ->
			add_score_calc(PassTime,HpHurt,1200,38,130000,12000);
		60 ->
			add_score_calc(PassTime,HpHurt,1200,44,156000,13000);
		65 ->
			add_score_calc(PassTime,HpHurt,1200,50,160000,15000);
		70 ->
			add_score_calc(PassTime,HpHurt,1200,55,184000,16000);
		75 ->
			add_score_calc(PassTime,HpHurt,1200,61,200000,10000);
		80 ->
			add_score_calc(PassTime,HpHurt,1200,66,220000,20000);
		85 ->
			add_score_calc(PassTime,HpHurt,1200,72,250000,21000);
		90 ->
			add_score_calc(PassTime,HpHurt,1200,77,280000,23000);
		95 ->
			add_score_calc(PassTime,HpHurt,1200,83,300000,25000);
		100 ->
			add_score_calc(PassTime,HpHurt,1200,88,330000,26000);
		_ ->
			[100,0]
	end.
		
add_score_calc(PassTime,HpHurt,T1,T2,V1,V2) ->
	TimeAdd = (T1 - PassTime) * T2 ,
	NewTimeAdd = 
	if
		TimeAdd > 100 ->
			TimeAdd;
		true ->
			100
	end,
	HpAdd = trunc((7 - 6 * HpHurt/V1)*V2),
	NewHpAdd = 
	if
		HpAdd > 100 ->
			HpAdd;
		true ->
			100
	end,
	[NewTimeAdd , NewHpAdd].

%%计算等级
calc_score_level(Stage,Value) ->
	case Stage of
		30 ->
			calc_score_level_fun(Value,20000);
		35 ->
			calc_score_level_fun(Value,30000);
		40 ->
			calc_score_level_fun(Value,40000);
		45 ->
			calc_score_level_fun(Value,50000);
		50 ->
			calc_score_level_fun(Value,60000);
		55 ->
			calc_score_level_fun(Value,70000);
		60 ->
			calc_score_level_fun(Value,80000);
		65 ->
			calc_score_level_fun(Value,90000);
		70 ->
			calc_score_level_fun(Value,100000);
		75 ->
			calc_score_level_fun(Value,110000);
		80 ->
			calc_score_level_fun(Value,120000);
		85 ->
			calc_score_level_fun(Value,130000);
		90 ->
			calc_score_level_fun(Value,140000);
		95 ->
			calc_score_level_fun(Value,150000);
		100 ->
			calc_score_level_fun(Value,160000);
		_ ->
			1
	end.
		

calc_score_level_fun(Value,PreValue) ->
	if
		Value < PreValue - PreValue / 6*5 ->
			1;
		Value >= PreValue - PreValue / 6*1 ->
			6;
		Value >= PreValue - PreValue / 6*2 ->
			5;
		Value >= PreValue - PreValue / 6*3 ->
			4;
		Value >= PreValue - PreValue / 6*4 ->
			3;
		Value >= PreValue - PreValue / 6*5 ->
			2;
		true ->
			1
	end.
%%
%% Local Functions
%%
get_stage_mon(Stage) ->
	case Stage of
		30 ->
			[{47902,1,6,29}];
		45 ->
			[{47909,1,18,33}];
		60 ->
			[{47918,1,20,40},{47918,1,20,42},{47918,1,19,41},{47918,1,21,41},{47919,1,20,41},{47933,1,19,34}];
		75 ->
			[{47925,1,12,18},{47926,1,3,25},{47927,1,21,25},{47928,1,7,34},{47929,1,17,34}];
		_ ->
			[]
	end.